package com.burgeon.backend.EnterpriseWeChat.rest.Gtasks;



import com.burgeon.backend.Rest.base.RESTBase;
import org.apache.http.util.TextUtils;
import org.json.JSONArray;
import org.springframework.util.MultiValueMap;

import java.util.HashMap;

public class addPhrase extends RESTBase {

    private String ip;
    private String account;
    private String password;

    public addPhrase(String ip, String account, String password) {
        this.ip = ip;
        this.account = account;
        this.password = password;
    }

    /**
     * 发送并接收字符创
     */

    public String getData(String content,String type) throws Exception {
        String url = "http://" + ip + "/servlets/binserv/Rest";

        String str = RESULT(Data(content, type), url);
        System.err.println("str="+str);
        String code = new JSONArray(str).getJSONObject(0).getString("code");

        if (!"0".equals(code)) {
            throw new Exception(str);
        }
        String objectid = new JSONArray(str).getJSONObject(0).getString("objectid");
        return objectid;
    }

    private MultiValueMap Data(String content,String type) {
        HashMap params = new HashMap();
        params.put("'RVISIT_CONTENT'",content);
        params.put("'RVISITLAE_TYPE'",type);

        params.put("table", "APP_VIP_RVISITLAE");//表名

        return DATA("ObjectCreate", params, account, password);
    }


    public static void main(String[] args) {
        addPhrase g = new addPhrase("59.110.28.94:90", "nea@burgeon.com.cn", "burgeon55321");
        try {
            g.getData("13643111382","1");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
